/**
 * 
 */
package org.i1510.spider.utils.spiderExt.router;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.i1510.common.utils.sqliteJdbc.DbUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * @author Administrator
 * 
 */
public class Html {

	/**
	 * @Author Rambo
	 * @Desc：获取//http://caibaojian.com/c/code 的数据列表
	 * @param doc
	 * @return TODO
	 * @Version Html.java,v 1.1 2014-11-13 下午2:26:35
	 */
	public List<Map> getCBJ(Document doc) {
		List<Map> list = new ArrayList<Map>();
		// 如果当前页面包含目标数据
		Elements els_list_item = doc.getElementsByClass("entry-title");

		for (Element el_list_item : els_list_item) {
			DbUtils db00 = new DbUtils();
			List<Map> dbList = db00.executeQuery("select * from job_caibaojian where " +
											"title ='"+el_list_item.getElementsByTag("a").text()
											+"' and href ='"+el_list_item.getElementsByTag("a").attr("href")+"';"); //查询数据 
			if(dbList.size() <= 0){
				Map map = new HashMap();
				map.put("title", el_list_item.getElementsByTag("a").text());
				map.put("href", el_list_item.getElementsByTag("a").attr("href"));
				list.add(map);
			}
			
		}
		return list;
	}
	/**
	*@Author Rambo
	*@Desc：获取//http://caibaojian.com/c/code 的数据列表明细数据
	*@param doc
	*@return TODO
	*@Version  Html.java,v 1.1 2014-11-13 下午3:12:14 
	*/
	public List<Map> getCBJ_dt(Document doc) {
		List<Map> list = new ArrayList<Map>();
		// 如果当前页面包含目标数据
		Map map = new HashMap();
		Elements els_title_item = doc.getElementsByClass("entry-title");
		if(els_title_item.size() > 0){
			map.put("title", els_title_item.get(0).text());
		}
		Elements els_con_item = doc.getElementsByClass("entry-content");
		if(els_con_item.size() > 0){
			map.put("descs", els_con_item.get(0).text());
		}
		
		list.add(map);
		return list;
	}

}
